﻿using System.Web;
using System.Web.Mvc;

namespace GrainManage.Web
{
    public class GrainManageExceptionAttribute : ActionFilterAttribute, IExceptionFilter
    {
        public void OnException(ExceptionContext filterContext)
        {
            log4net.ILog log = log4net.LogManager.GetLogger("LogToSqlite");
            var url = HttpContext.Current.Request.RawUrl;
            log.Error(url, filterContext.Exception);
            filterContext.ExceptionHandled = true;
            UrlHelper helper = new UrlHelper(filterContext.RequestContext);
            filterContext.Result = new RedirectResult(helper.Action("ShowError", "Error"));
        }
    }
}